/*  
 *  Copyright 2006 Paul Jack.
 *
 *  This file is part of the Dex compiler suite. 
 *  
 *  Dex is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or (at your
 *  option) any later version.
 *  
 *  Dex is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 *  Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
package dex.compiler.model.expression;


import dex.compiler.model.base.Place;


/**
 * A member expression, such as <code>x.foo</code>.  
 *
 */
public class MemberExpression extends Expression {
	
	
	/**
	 * The owner of this expression.  Must evaluate to a 
	 * record or a class type.
	 */
	private Expression owner;
	
	
	/**
	 * The name of the member being accessed.
	 */
	private String memberName;
	

	/**
	 * Constructs a new member expression.
	 * 
	 * @param place  the place where the member originated
	 * @param owner  the owner of the structure whose member to access
	 * @param memberName  the name of member to access
	 */
	public MemberExpression(Place place, Expression owner, String memberName) {
		super(place);
		if (owner == null) {
			throw new IllegalArgumentException();
		}
		if (memberName == null) {
			throw new IllegalArgumentException();
		}
		this.owner = owner;
		this.memberName = memberName;
	}

	@Override
	public String toString() {
		return owner + "." + memberName;
	}

	
	/**
	 * Returns the owner of this member expression.
	 * 
	 * @return  the owner
	 */
	public Expression getOwner() {
		return owner;
	}

	
	/**
	 * Returns the name of the member to be accessed.
	 * 
	 * @return  the member name
	 */
	public String getMemberName() {
		return memberName;
	}


}
